package com.android.lovely.data

import android.os.Parcelable
import androidx.core.graphics.toColorInt
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import kotlinx.parcelize.Parcelize

/**
 *
 * @author why
 * @date 2025/2/25 21:39
 */
@JsonClass(generateAdapter = true)
data class PayData(
    @Json(name = "first_pay") val firstPay: PayDetail? = null,
    @Json(name = "list") val list: List<PayDetail> = listOf()
)

@Parcelize
@JsonClass(generateAdapter = true)
data class PayDetail(
    @Json(name = "id") val id: Int = 0,
    @Json(name = "name") val name: String = "", // 套餐名
    @Json(name = "type") val type: Int = 0,
    @Json(name = "price") val price: Double = 0.0, // 现价
    @Json(name = "old_price") val oldPrice: Double = 0.0, // 原价
    @Json(name = "point") val point: Int = 0, // 获得宝石数
    @Json(name = "attr_info") val attrInfo: String = "",
    @Json(name = "status") val status: Int = 0,
    @Json(name = "c_time") val createTime: String = "",
    @Json(name = "u_time") val updateTime: String = "",
    @Json(name = "apple_id") val appleId: String = "" // adapty 后台的 product_id，即SKU
) : Parcelable

@JsonClass(generateAdapter = true)
data class TransactionListBean(
    @Json(name = "c_time") val cTime: String = "",
    @Json(name = "id") val id: Int = 0,
    @Json(name = "msg") val msg: String = "",
    @Json(name = "num") val num: Int = 0,
    @Json(name = "surplus") val surplus: Int = 0,
    @Json(name = "type") val type: Int = 0,
    @Json(name = "user_id") val userId: Int = 0
) {
    fun getDisplayText(): String {
        return if (num > 0) "+$num" else num.toString()
    }

    fun getTextColor(): Int {
        return if (num > 0) "#7673FE".toColorInt() else "#FFFFFF".toColorInt()
    }
}